<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tk="http://www.qdocuments.net" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="tk msxsl">
  <xsl:import href="ListFrame_Trans.xslt"/>
  <xsl:import href="PageListItems.xslt"/>
  <xsl:import href="ListItems.xslt"/>
  <xsl:import href="PublicItems.xslt"/>
  <xsl:import href="PublicEditItems.xslt"/>
  <xsl:variable name="tk:Toolkit" select="/Toolkit"/>
  <xsl:variable name="tk:XmlFile"/>
  <xsl:variable name="tk:Tables" select="document($tk:XmlFile/Toolkit/tk:Module/tk:Resolvers/tk:Resolver[@List='true']/tk:Xml)/Toolkit/tk:Table"/>
  <xsl:variable name="tk:Searches" select="$tk:Tables/tk:Field[tk:List/@HtmlCtrl != '' and tk:Extension/@Search = 'title']"/>
  <xsl:template name="tk:PostScript">
    <script language="JavaScript">
    function Post2()
    {
      var TableName = "<xsl:value-of select="$tk:Tables/@TableName"/>";
      var FieldNames = "<xsl:apply-templates select="$tk:Searches" mode="tk:SearchScript"/>" + ",query";
      PostData(TableName, FieldNames, "<xsl:value-of select="$tk:DSelfURL"/>", "", "");
    }
    function KeyUp(value, ctrl)
    {
      if (value == "")
        ctrl.value = "";
      else if (value == "~")
        ctrl.value = "~";
    }
    function changePage()
    {
        var eCtrl = window.event.srcElement;
        if (eCtrl == document.all('btnGoto', 0))
            eTmp = 0;
        else
            eTmp = 1;
        var pCtrl = document.all('MyPageID', eTmp);
        if (pCtrl == null) return;
        if (IsInteger(pCtrl.value) &amp;&amp; parseInt(pCtrl.value) > 0)
        {
            document.location.href = "<xsl:value-of select="concat($tk:ListHeadUrl, $tk:ListOrder)"/>" + "&amp;Page=" + pCtrl.value; 
        }
    }
    </script>
  </xsl:template>
  <xsl:template match="tk:Field" mode="tk:SearchScript">
    <xsl:if test="position()!=1">,</xsl:if>
    <xsl:value-of select="tk:FieldName"/>
    <xsl:if test="tk:Extension/@DateSpan">,<xsl:value-of select="tk:FieldName"/>END</xsl:if>
    <xsl:if test="tk:EasySearch">,hd<xsl:value-of select="tk:FieldName"/>
    </xsl:if>
  </xsl:template>
  <xsl:template match="tk:Table" mode="tk:List">
    <xsl:variable name="FieldList">
      <xsl:for-each select="$tk:Tables/tk:Field[tk:List[@HtmlCtrl != 'Hidden']]">
        <xsl:sort select="tk:List/@Order" data-type="number"/>
        <xsl:copy-of select="."/>
      </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="FieldNodes" select="msxsl:node-set($FieldList)/*"/>
    <table cellspacing="1" cellpadding="1" border="0" width="100%" class="listtb">
      <tr>
        <xsl:call-template name="tk:OperationHead"/>
        <xsl:apply-templates select="$FieldNodes" mode="tk:ListHead"/>
      </tr>
      <!--the DataList-->
      <xsl:variable name="Data" select="$tk:Toolkit/*[local-name()=current()/@TableName]"/>
      <xsl:choose>
        <xsl:when test="count($Data) &gt; 0">
          <xsl:call-template name="tk:ShowList">
            <xsl:with-param name="Data" select="$Data"/>
            <xsl:with-param name="FieldList" select="$FieldNodes"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:copy-of select="$tk:NoRecord"/>
        </xsl:otherwise>
      </xsl:choose>
    </table>
  </xsl:template>
  <xsl:template name="tk:ShowList">
    <xsl:param name="Data"/>
    <xsl:param name="FieldList"/>
    <xsl:for-each select="$Data">
      <tr valign="top" class="td-bg" onmouseover="this.style.backgroundColor = '#F9F9F0';" onmouseout="this.style.backgroundColor = '';">
        <xsl:apply-templates select="$tk:XmlFile/Toolkit/tk:Module" mode="tk:Operation">
          <xsl:with-param name="DataRecord" select="current()"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="$FieldList" mode="tk:Item">
          <xsl:with-param name="DataRecord" select="."/>
        </xsl:apply-templates>
      </tr>
    </xsl:for-each>
  </xsl:template>
  <xsl:template match="tk:Field" mode="tk:ListHead">
    <xsl:choose>
      <xsl:when test="@DataType='text' or tk:List/TextHead">
        <xsl:call-template name="tk:NoSortColHead">
          <xsl:with-param name="Title" select="tk:DisplayName"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$tk:Sort/SortField=position()">
        <xsl:call-template name="tk:SortColHead">
          <xsl:with-param name="Title" select="tk:DisplayName"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="tk:ColHead">
          <xsl:with-param name="Title" select="tk:DisplayName"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="tk:Field" mode="tk:Item">
    <xsl:param name="DataRecord"/>
    <xsl:call-template name="tk:DisplayListItem">
      <xsl:with-param name="DataRecord" select="$DataRecord"/>
      <xsl:with-param name="FieldList" select="$tk:Tables/tk:Field"/>
      <xsl:with-param name="Source" select="$tk:Source"/>
      <xsl:with-param name="DListRefParams" select="$tk:XmlFile/Toolkit/tk:Module/tk:Resolvers/tk:Resolver[@List='true']/tk:DListRefParams"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="tk:Module" mode="tk:Operation">
    <xsl:param name="DataRecord"/>
    <xsl:call-template name="tk:Operation">
      <xsl:with-param name="FieldList" select="$tk:Tables/tk:Field"/>
      <xsl:with-param name="DataRecord" select="$DataRecord"/>
      <xsl:with-param name="Source" select="$tk:Source"/>
      <xsl:with-param name="DListRefParams" select="tk:Resolvers/tk:Resolver[@List='true']/tk:DListRefParams"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="tk:Module[tk:DataSet='List' or tk:DataSet='ListXml' or tk:DataSet='ListDetail' or tk:DataSet='ListDetailXml' or tk:DataSet='AllRow' or tk:DataSet='AllRowXml']" mode="tk:Operation">
    <xsl:param name="DataRecord"/>
    <xsl:call-template name="tk:EmptyOperation"/>
  </xsl:template>
</xsl:stylesheet>
